package com.miao.service.impl;

import com.miao.dao.AuthenticationDao;
import com.miao.entity.Authentication;
import com.miao.service.AuthenticationService;
import com.miao.util.BeanCopyUtil;
import com.miao.vo.AuthenticationVo;
import com.miao.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 27523
 */
@Service
public class AuthenticationServiceImpl implements AuthenticationService {
    @Autowired
    AuthenticationDao authenticationDao;

    @Override
    public ResultVo add(AuthenticationVo authenticationVo) {
        Authentication authentication = new Authentication();
        BeanCopyUtil.copyProperties(authenticationVo, authentication);
        Integer integer = authenticationDao.add(authentication);
        return ResultVo.success(integer);
    }

    @Override
    public ResultVo selectById(Integer userId) {
        Authentication authentication = authenticationDao.selectById(userId);
        AuthenticationVo authenticationVo = new AuthenticationVo();
        BeanCopyUtil.copyProperties(authentication, authenticationVo);
        return ResultVo.success(authenticationVo);
    }
}
